package com.abel.quiz.controller;/**
 * Created by abel.lin on 2017/8/30.
 */

import com.abel.quiz.common.LotteryUtil;
import com.abel.quiz.common.vo.AjaxResp;
import com.abel.quiz.common.vo.LotteryAwards;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * @author abel.lin
 * @date_time 2017/8/30 15:56
 * @description
 */
@RequestMapping("admin/exer")
@Controller
public class ExerciseController {
    @RequestMapping("wheel")
    public ModelAndView wheel(HttpServletRequest request, HttpServletResponse response){
        ModelAndView view = new ModelAndView("admin/exer/wheel");

        return view;
    }

    @ResponseBody
    @RequestMapping("doLottery")
    public String doDel(HttpServletRequest request, HttpServletResponse response){
        AjaxResp ajax = new AjaxResp(AjaxResp.CodeArgs.OK);
        List<LotteryAwards> initDrawList = new ArrayList<LotteryAwards>() {{
            add(new LotteryAwards(0, "一等奖", 1.0));
            add(new LotteryAwards(1, "二等奖", 2.0));
            add(new LotteryAwards(2, "三等奖", 7.0));
            add(new LotteryAwards(3, "四等奖", 10.0));
            add(new LotteryAwards(4, "转多次", 30.0));
            add(new LotteryAwards(5, "谢谢", 50.0));
        }};

        LotteryAwards domain = LotteryUtil.lottery(initDrawList);
        ajax.setData(domain);
        return ajax.toJson();
    }
}

